<template>
  <a-card :bordered="false">

<!-- 页头区域-->
 <a-page-header
    style="border: 1px solid rgb(235, 237, 240)"
  >
   <p style="float:left"><b><font size="4">面料折扣体系名称:{{this.$route.query.fabricDiscountSystemName}}</font></b>&nbsp; &nbsp;</p>
 </a-page-header>
 
<br>

<p><h3><b>添加阶梯售价</b></h3></p>

    <!-- 操作按钮区域 -->

    <!-- table区域-begin -->
    <div>
 
  <a-list
    class="demo-loadmore-list"
    :loading="loading"
    item-layout="horizontal"
    :data-source="data"
  >
    <a-list-item slot="renderItem" slot-scope="item, index">
         <a-input  v-model="item.minNumbers"  disabled="true" style="width: 150px"></a-input>米--
            <a-input  v-model="item.maxNumbers"  disabled="true" style="width: 150px"></a-input>米&nbsp;&nbsp;
               <a-input  v-model="item.discountRatio" disabled="true"  style="width: 150px"></a-input>折扣
      <!-- {{item.minNumbers}} 件--
        {{item.maxNumbers}} 件&nbsp;&nbsp;
        {{item.price}} 元 -->
         <a-button   @click="deletethis(item.id)" >-</a-button> 
    </a-list-item>
  </a-list>
 <div>
   <br/>
    <a-button  style="width: 500px;height: 36px;"  @click="xianshi=true">添加</a-button>
     <br/>
    </div>

<div v-if="xianshi">  
  <a-input v-model="minNumbers" style="width: 150px"/> 米--
    <a-input v-model="maxNumbers" style="width: 150px"/> 米
     <a-input v-model="discountRatio" style="width: 150px"/> 折扣
     
</div>
   <br/>
   <a-button type="primary" style="color: #F9D532;width: 80px;height: 36px;background: #333333;border-style: none;"  @click="addInerval">保存</a-button>&nbsp;&nbsp;
    <!-- <a-button  style="width: 80px;height: 36px;;"   @click="retrunshoujia">取消</a-button> -->
    </div>
    <!-- table区域-end -->
  </a-card>
</template>

<script>

  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'
  import {getAction,postAction} from "../../api/manage";
  import Qs from 'qs'

  export default {
      name: "mianliaojietidiscount",
    mixins: [JeecgListMixin],
    components: {
      JInput,
    },
    data() {
      return {
        xianshi:false,
        discountRatio:'',
        minNumbers:'',
        maxNumbers:'',
        data:[],
        ordertypeString:'',
        description: '这是新增装箱单',
        boxName: '', // 装箱单名称
        remark: '', // 备注
        queryParam: {},
        recycleBinVisible: false,
        productList: [], // 产品列表
        columns: [
          // {
          //   title: '序号',
          //   dataIndex: '',
          //   key: 'rowIndex',
          //   width: 60,
          //   sorter: true,
          //   align: "center",
          //   customRender: function (t, r, index) {
          //     return parseInt(index) + 1;
          //   }
          // },
          {
            title: '品类',
            align: "center",
            dataIndex: 'parentName',
            width: 120,
            sorter: true
          },
          {
            title: '业务类型',
            align: "center",
            width: 80,
            dataIndex: 'businessType',
            sorter: true,
                 customRender: (businessType) => {
              //字典值替换通用方法
              if(businessType==0)
              return "个订业务";
              else  if(businessType==1)
              return "团订业务";
              else
              return "标准码业务";
            }
          },
          {
            title: '工艺类型',
            align: "center",
            width: 100,
            dataIndex: 'categoryName'
          },
          {
            title: '新增时间',
            align: "center",
            width: 100,
            dataIndex: 'createTime'
          },
          {
            title: '状态',
            align: "center",
            width: 100,
            dataIndex: 'status',
                   customRender: (status) => {
              //字典值替换通用方法
              if(status==0)
              return "未设置";
              else  if(status==1)
              return "已设置";
            }
          },
     {
            title: '设置售价',
            dataIndex: 'action',
              width: 100,
            align: "center",
            scopedSlots: {
              filterDropdown: 'filterDropdown',
              filterIcon: 'filterIcon',
              customRender: 'action'},
          }
        ],
        url: {
          list: "/Discount/mianliaojietidiscountlist?fabirDiscountSystemId="+this.$route.query.id,  
          delete:"/Discount/deletemianliaojieti",
          add:"/Discount/addfabicDiscountjieti" 
        },
      }
    },
    computed: {
      /*importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }*/
    },
    created() {

          this.getpriceInervallist();
    },
    methods: {
//点击取消后回到售价列表
 retrunshoujia(){
    // this.$router.push({path:'/storeCenter/Price'
    //       })
 }, 
      addInerval(){
        console.log("这没东西呗")
        let formdata={
            'fabirDiscountSystemId':this.$route.query.id,
            'minNumbers':this.minNumbers,
             'maxNumbers':this.maxNumbers,
              'discountRatio':this.discountRatio
        }
              postAction(this.url.add,formdata).then((res)=>{
              if(res.success){
                 this.$message.success(res.message);
                 this.getpriceInervallist();
                 this.xianshi=false;
                 this.minNumbers='';
                   this.maxNumbers='';
                     this.discountRatio='';
              } else{
               this.$message.error(res.message);
              }
              
              })
      },
      deletethis(id){
             getAction(this.url.delete,{id:id}).then((res)=>{
              if(res.success){
                 this.$message.success(res.message);
                 this.getpriceInervallist();
              } else{
               this.$message.error(res.message);
              }
              
              })
      },
     getpriceInervallist(){
        getAction(this.url.list).then((res)=>{
              if(res.success){
                this.data=res.result;
               
              } })

     },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>